print("======捕获所有异常======")
try:
    n = 1 / 0
except:
    print("异常")
finally:
    print("finally")

try:
    n = 1 / 0
except Exception as e:
    print("异常:", e)
finally:
    print("finally")

print("=====捕获指定异常=========")
try:
    n = 1 / 0
except ZeroDivisionError as e:
    print("异常:", end="")
    print(e)
finally:
    print("finally")

try:
    n = 1 / 0
except(ZeroDivisionError, NameError) as e:
    print("异常:", end="")
    print(e)
finally:
    print("finally")

print("=====异常的传递=========")


def funcA(x):
    n = 100 / x
    return n


def funcB(x):
    n = funcA(x)
    return n


try:
    print(funcB(5))
    print(funcB(0))
except Exception as e:
    print(f"捕获到异常: {e}")
